﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RockPaperScissors.DataModel;

namespace RockPaperScissors.Web
{
    public static class SettingsHelper
    {
        public static int GetRoundNumber()
        {
            int tmpRtn = 1;

            DataModel.RockPaperScissors context = new DataModel.RockPaperScissors();
            Setting roundSetting = context.Settings.SingleOrDefault(setting => setting.SettingName == "RoundNumber");
            tmpRtn = Convert.ToInt32(roundSetting.SettingValue);
            context.SaveChanges();

            // return
            return tmpRtn;
        }

        public static void SetRoundNumber(int roundNumber)
        {
            DataModel.RockPaperScissors context = new DataModel.RockPaperScissors();
            Setting roundSetting = context.Settings.SingleOrDefault(setting => setting.SettingName == "RoundNumber");
            roundSetting.SettingValue = roundNumber.ToString();
            context.SaveChanges();
        }
    }
}